package com.jie.jie.mvp.ui;

import android.content.Intent;
import android.view.KeyEvent;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jaydenxiao.common.base.BaseActivity;
import com.jie.jie.R;

import butterknife.Bind;
import butterknife.OnClick;

public class GanhuoActivity extends BaseActivity {

    @Bind(R.id.back_iv)
    ImageView backIv;
    @Bind(R.id.title_tv)
    TextView titleTv;
    @Bind(R.id.mvp_wv)
    WebView mvpWv;
    @Bind(R.id.activity_ganhuo)
    LinearLayout activityGanhuo;

    @Override
    public int getLayoutId() {
        return R.layout.activity_ganhuo;
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public void initView() {
        Intent intent = getIntent();
        String url = intent.getStringExtra("url");
        mvpWv.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        mvpWv.getSettings().setJavaScriptEnabled(true);
        mvpWv.loadUrl(url);
        mvpWv.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {

                view.loadUrl(url);
                return true;
            }
        });
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event)
    {
        if ((keyCode == KeyEvent.KEYCODE_BACK) && mvpWv.canGoBack()) {
            mvpWv.goBack();
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    @OnClick(R.id.back_iv)
    public void onClick() {
        finish();
    }
}
